//
//  Course.m
//  KeepProject
//
//  Created by amos on 16/1/20.
//  Copyright © 2016年 itheima. All rights reserved.
//

#import "Course.h"

@implementation Course

+ (instancetype)courseWithDict:(NSDictionary*)dict
{
    id course = [[self alloc] init];

    [course setValuesForKeysWithDictionary:dict];

    return course;
}

+ (NSArray*)coursesWithPlist
{
    //1.获取文件位置
    NSString* path = [[NSBundle mainBundle] pathForResource:@"CoursesList.plist" ofType:nil];

    //2.获取文件数据
    NSArray* dictArr = [NSArray arrayWithContentsOfFile:path];

    //3.用于存储模型的数组
    NSMutableArray* modelArr = [NSMutableArray arrayWithCapacity:dictArr.count];

    //4.遍历 dictArr
    for (NSDictionary* dict in dictArr) {

        Course* course = [Course courseWithDict:dict];

        [modelArr addObject:course];
    }

    return modelArr.copy;
}

@end
